package com.zbf.web;

import com.zbf.dao.TestDao2;
import com.zbf.dao2.TestDao3;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/3/24  0:48
 * 描述:
 */
@RestController
public class TestMoreController {

    @Autowired
    TestDao3 testDao3;

    @Autowired
    TestDao2 testDao2;

    @RequestMapping("testDb6")
    @Transactional(rollbackFor = Exception.class,value = "datasourceTransactionManager2")
    public void test15(){
        Map<String,Object> map=new HashMap<>();
        map.put("id",3);
        map.put("quantity",100);
        int i = testDao3.updateStock(map);
        testDao2.updateOrder02(map);
        if(i==1){
            throw new RuntimeException("=========6回滚======");
        }

    }


    @RequestMapping("testDb2")
    public void test16(){
        Map<String,Object> map=new HashMap<>();
        map.put("id",3);
        map.put("quantity",1000);
        testDao2.updateOrder02(map);
    }




}
